#!/bin/bash
set -e
PNAME=wowiot
JAR_PATH=/mnt/app/wowiot/${PNAME}.jar
LOG_FILE_NAME=/mnt/logs/wowiot/sys-info.log
echo ${LOG_FILE_NAME}

PID=`ps -ef |grep java |grep ${PNAME} |awk '{print $2}'`
if [ -n "$PID" ];then
    kill -9 $PID
    sleep 2s
fi
nohup java -Dspring.profiles.active=prod -Dlogging.file.name=${LOG_FILE_NAME} -Xms1G -Xmx1G -XX:MetaspaceSize=256M -XX:MaxMetaspaceSize=256M -XX:-UseAdaptiveSizePolicy -XX:+UseConcMarkSweepGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintHeapAtGC -jar ${JAR_PATH} > /dev/null &

sleep 4s
tail -f ${LOG_FILE_NAME}